package com.briup.mt.service.impl;

import com.briup.mt.bean.BaseLog;
import com.briup.mt.bean.BaseLogExample;
import com.briup.mt.dao.BaseLogMapper;
import com.briup.mt.service.IBaseLogService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;
@Service
public class BaseLogServiceImpl implements IBaseLogService {
    @Resource
    private BaseLogMapper baseLogMapper;
    @Override
    public List<BaseLog> query(String realname, String method) {
        BaseLogExample example=new BaseLogExample();
        if(!StringUtils.isEmpty(realname)){
            example.createCriteria().andRealnameLike("%"+realname+"%");
        }
        if(!StringUtils.isEmpty(method)){
            example.createCriteria().andMethodEqualTo(method);
        }
        List<BaseLog> list=baseLogMapper.selectByExample(example);
        return list;
    }

    @Override
    public void saveOrUpdate(BaseLog baseLog) {
        if(baseLog.getId()==null){
            baseLogMapper.insert(baseLog);
        }else{
            baseLogMapper.updateByPrimaryKey(baseLog);
        }
    }

    @Override
    public void deleteById(long id) {
        baseLogMapper.deleteByPrimaryKey(id);
    }

}
